const nodeChart = echarts.init(document.getElementById('node_info'));
const nodeChartSchedulable = echarts.init(document.getElementById('node_schedulable'));
const nodeChartCPU = echarts.init(document.getElementById('node_cpu'));
const nodeChartMemory = echarts.init(document.getElementById('node_memory'));
option = {
    title: {
        text: '',
        left: 'center'
    },
    tooltip: {
        trigger: 'item'
    },
    legend: {
        orient: 'vertical',
        left: 'bottom'
    },
    series: [
        {
            name: '节点健康信息',
            type: 'pie',
            radius: '40%',
            data: [
                {value: 0, name: '未就绪', itemStyle: {color: "red"}},
                {value: 0, name: '就绪', itemStyle: {color: "green"}},
            ],
            emphasis: {
                itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};

optionSchedulable = {
    title: {
        text: '',
        left: 'center'
    },
    tooltip: {
        trigger: 'item'
    },
    legend: {
        orient: 'vertical',
        left: 'bottom'
    },
    series: [
        {
            name: '节点调度资源',
            type: 'pie',
            radius: '40%',
            data: [
                {value: 0, name: '不可调度', itemStyle: {color: "red"}},
                {value: 0, name: '可调度', itemStyle: {color: "green"}},
            ],
            emphasis: {
                itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};


optionNodeCPU = {
    title: {
        text: '',
        left: 'center'
    },
    tooltip: {
        trigger: 'item'
    },
    legend: {
        orient: 'vertical',
        left: 'bottom'
    },
    series: [
        {
            name: '可分配的CPU',
            type: 'pie',
            radius: '40%',
            data: [
                {value: 0, name: '不可分配', itemStyle: {color: "red"}},
                {value: 0, name: '可分配', itemStyle: {color: "green"}},
            ],
            emphasis: {
                itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};

optionNodeMemory = {
    title: {
        text: '',
        left: 'center'
    },
    tooltip: {
        trigger: 'item'
    },
    legend: {
        orient: 'vertical',
        left: 'bottom'
    },
    series: [
        {
            name: '可分配的内存',
            type: 'pie',
            radius: '40%',
            data: [
                {value: 0, name: '不可分配', itemStyle: {color: "red"}},
                {value: 0, name: '可分配', itemStyle: {color: "green"}},
            ],
            emphasis: {
                itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};

function ChartTable(id, node_cpu, node_requests_cpu) {
    const ChartName = echarts.init(document.getElementById(id));
    option = {
        series: [
            {
                name: 'Access From',
                type: 'pie',
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                label: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    label: {
                        show: false,
                        fontSize: 40,
                        fontWeight: 'bold'
                    }
                },
                labelLine: {
                    show: false
                },
                data: [
                    {value: 0, name: '总数'},
                    {value: 0, name: '占用数'},
                ]
            }
        ]
    };
    option.series[0].data[0].value = node_cpu
    option.series[0].data[1].value = node_requests_cpu
    option && ChartName.setOption(option);
}